
<extend name="Public/base" />
<block name="style">
    <style type="text/css">
    .code{
        width: 135px;
        height:40px;
        border:none;
        background: #4BBD00;
        color: #fff;

    }
    .real_status{
        width: 135px;
        height:40px;
        border:none;
        background: #4BBD00;
        color: #fff;

    }

    p{
        height:50px;
        line-height: 50px;
        font-size: 18px;
        margin-top: 20px;
    }


    </style>
</block>
<block name="body">
    <div class="main-title">
        <h2>口碑商户资料</h2>
    </div>
    



    <form action="{:U()}" method="post" class="form-horizontal">


        <php>
            
            if(empty($_list['status'])){
                $tatus=0;
            }else{
                $status=1;
            }

        </php>

        <div class="form-item">
            <label class="item-label">授权码<span class="check-tips" style="color:red;">（以此获取授权信息，使用一次后失效，切记保存）</span></label>
            <div class="controls">
                <input type="text" style="height:30px;" class="text input-large app_auth_code" readonly="readonly" name="app_auth_code" value="{$_list.app_auth_code}">
            </div>
            <input type="button" class="code" id="code" value="获取授权令牌">
        </div>
        <div class="form-item">
            <label class="item-label">回扣费率</label>
            <div class="controls">
                <input type="text" style="height:30px;" class="text input-large" name="rate" value="{$_list.rate}">
            </div>
        </div>
            <div class="form-item">
                <label class="item-label">授权令牌（app_auth_token）</label>
                <div class="controls">
                    <input type="text" style="height:30px;" class="text input-large" <eq name="status" value="1">disabled</eq>  name="app_auth_token" value="{$_list.app_auth_token}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">刷新令牌（app_refresh_token）</span></label>
                <div class="controls">
                    <input type="text" style="height:30px;" class="text input-large" <eq name="status" value="1">disabled</eq> name="app_refresh_token" value="{$_list.app_refresh_token}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">授权商户app_id（auth_app_id）</span></label>
                <div class="controls">
                    <input type="text" style="height:30px;" class="text input-large" <eq name="status" value="1">disabled</eq> name="auth_app_id" value="{$_list.auth_app_id}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">授权商户id（user_id）</span></label>
                <div class="controls">
                    <input type="text" style="height:30px;" class="text input-large" <eq name="status" value="1">disabled</eq> name="user_id" value="{$_list.user_id}">
                </div>
            </div>
        
        <div class="form-item">
            授权令牌有效时间：365天，刷新令牌有效时间：372天，授权令牌失效后请及时使用刷新令牌重新获取授权令牌。
        </div>




        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="button" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            <php>
                if($_list['use_status']==0){
                    echo '<span class="btn  sj" style="width:132.167px;height:38px;text-align:center;padding:0px;line-height:38px;">点击上架使用</span>';
                }else{
                    echo '<span class="btn  xj" style="width:132.167px;height:38px;text-align:center;padding:0px;line-height:38px;">点击下架</span>';
                }
            </php>

            <span class="btn  sq" style="width:132.167px;height:38px;text-align:center;padding:0px;line-height:38px;">解除授权</span>


        </div>

        
    </form>
</block>
<block name="script">


    <script type="text/javascript">

        Think.setValue("extend", {$info.extend|default=0});
            //导航高亮
            highlight_subnav('{:U('index')}');

        $('#code').click(function(){
            var code=$('.app_auth_code').val();
            location.href="{:U('Alipay/get_token?code=')}"+code;
        })

        $('#submit').click(function(){
            var data=$('form').serializeArray();
            $.ajax({
                type:'post',
                url:'',
                data:data,
                success:function(m){
                    if(m==1){
                        alert('修改成功！');
                        location.href="{:U('index')}";
                    }else if(m==0){
                        alert('修改失败！');
                    }else{
                        alert(m)
                    }
                }

            })
        })

        $('.sq').click(function(){
            
            var app_auth_code=$('.app_auth_code').val();
            // alert(app_auth_code)
            $.ajax({
                type:'post',
                data:{'app_auth_code':app_auth_code,'type':1},
                url:"{:U('shouquan')}",
                success:function(m){
                    // alert(m)
                    if(m==1){
                        alert('解除成功！');
                        location.href="{:U('index')}";
                    }else if(m==0){
                        alert('解除失败！');
                    }else{
                        alert(m)
                    }
                }
            })

        })
        $('.sj').click(function(){
            
            var app_auth_code=$('.app_auth_code').val();
            // alert(app_auth_code)
            $.ajax({
                type:'post',
                data:{'app_auth_code':app_auth_code,'type':2},
                url:"{:U('shouquan')}",
                success:function(m){
                    // alert(m)
                    if(m==1){
                        alert('操作成功！');
                        location.href="{:U('index')}";
                    }else if(m==0){
                        alert('操作失败！');
                    }else{
                        alert(m)
                    }
                }
            })

        })
        $('.xj').click(function(){
            
            var app_auth_code=$('.app_auth_code').val();
            // alert(app_auth_code)
            $.ajax({
                type:'post',
                data:{'app_auth_code':app_auth_code,'type':3},
                url:"{:U('shouquan')}",
                success:function(m){
                    // alert(m)
                    if(m==1){
                        alert('操作成功！');
                        location.href="{:U('index')}";
                    }else if(m==0){
                        alert('操作失败！');
                    }else{
                        alert(m)
                    }
                }
            })

        })

    </script>

<!-- app_auth_token":"201712BBdf7f602ee00f4a6ca88e1116f468bD12","app_refresh_token":"201712BBc70480b713d141529bf20d71c1cb4B12","auth_app_id":"2017051207213149","user_id":"2088721036926123"} -->

</block>

